package com.situ.pattern.observer2;

import java.util.Observable;
import java.util.Observer;

public class Reader implements Observer {
    private String name;

    public Reader(String name) {
        this.name = name;
    }

    @Override
    public void update(Observable o, Object arg) {
        System.out.println(arg);
        //这是采用推的方式
        System.out.println(name + "收到报纸内容：" + arg);
        //这是拉取方式
        System.out.println(name + "收到报纸内容：" + ((NewsPaper)o).getContent());
    }
}
